<?php
header("Content-Type:json/html;charset=utf8");

$config = require '../config.php';
require '../validToken.php';
$conn = new mysqli($config['servername'], $config['username'], $config['password'], $config['dbname']);
$info = isValidToken($conn);

if($info['status']){
    $author = $_POST['author'];
    $word = $_POST['word'];
    $icon_src = $_POST['icon_src'];

    $sql = "update website set author='$author', word='$word', icon_src='$icon_src'";

    $result = $conn->query($sql);
    if($result){
        $result = ['code' =>1,  'msg' => "更改配置信息成功!"];
        require "../util/savelog.php";
        saveLog($conn, $info['user']['id'], "更改了配置信息");
    }else{
        $result = ['code' =>0,   'msg' => "更改配置信息成功!"];
    }
}else{
    $result = ['code' =>-1,   'msg' => "token失效!"];
}
print_r(json_encode($result));

